// pages/detail/detail.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detail: null,  loading:true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.id) {
      app.get("/detail", {
        op: "id",
        data: options.id
      }, (e) => {
        if (e.data.length === 0) {
          return;
        }
        let obj = app.towxml(e.data[0].body, 'markdown');
        e.data[0].body = obj;
        e.data[0].update_time = app.util.formatTime(e.data[0].update_time);
        this.setData({
          loading:false,
          detail: e.data[0]
        })
      });
    }
  },

  onShareAppMessage: function () {
    if(this.data.detail!==null){
      return {
        title: this.data.detail.title,
        path: '/pages/detail/detail?id=' + this.data.detail.id,
      }
    }
  }
})